<?php
    require_once"../include/dbclass.php";
    $pdo = new DB();
    $current_id = $_REQUEST['id'];  //获取文章ID
    require_once "tpl/head.html";
    $page_title = "文章编辑";
    require_once "tpl/header.html";
    $nav_index = "";
    $nav_article = "style='background-color:rgba(255,255,255,.2);'";
    $nav_link = "";
    require_once "tpl/nav.html";


if (isset($_POST['update'])){    //文章标题不能为空


        $title = $_POST['title'];
        $editor = $_POST['editor'];
        $date = $_POST['date'];
        $content = $_POST['content'];

        $q = 'update article set title=?,editor=?,date=?,content=?where id=?';

        $pdo -> update($q,$title,$editor,$date,$content,$current_id);
    }


    $q = 'select * from article where id='.$current_id;
    $results = $pdo->getall($q);
    foreach($results as $key=>$value){
        $id = $value['id'];
        $title = $value['title'];
        $editor = $value['editor'];
        $date = $value['date'];
        $content = $value['content'];
}

    require_once "tpl/article_edit.html";
    require_once "tpl/footer.html";

    //文章编辑逻辑
